<?php
/**
 * Created by JetBrains PhpStorm.
 * User: scala
 * Date: 12-10-16
 * Time: 下午5:31
 * To change this template use File | Settings | File Templates.
 */
class SuccessCaseAction extends Action
{

    public function index(){
        $case=M("SuccessCase");
        import("ORG.Util.Page");// 导入分页类
        $count=$case->count();
        $Page= new Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数
        $Page->setConfigArray(array('header'=>'条成功案例','prev'=>'<input type="button" value="<<">','next'=>'<input type="button" value=">>">','first'=>'首页','last'=>'尾页','theme'=>' %totalRow% %header% %nowPage%/%totalPage% 页   %first% %prePage% %upPage%   <span style="color: red;">%linkPage%</span>   %downPage% %nextPage% %end%'));
        $show=$Page->show();//分页显示输出
        $list=$case->limit($Page->firstRow.",".$Page->listRows)->select();
        $this->assign("list",$list);
        $this->assign('page',$show);// 赋值分页输出
        $caseimg=M("CaseImg");
        $imgList=$caseimg->where("mainimg=1")->select();
        $this->assign("imgList",$imgList);
		
		$article=M("StaffArticle");
		$user=M("User");
		$centlist=$article->limit('0,3')->order("createtime desc")->select();
        $userList=$user->select();
		$this->assign("centlist",$centlist);
        $this->assign("userList",$userList);
        $this->display();
    }
	
	public function detail(){
        if(!empty($_GET['id'])){
            $case=M("SuccessCase");
            $list=$case->find($_GET['id']);
            $img=M("CaseImg");
            $imgList=$img->where("caseid=".$_GET['id'])->select();
            $this->assign("list",$list);
            $this->assign("imgList",$imgList);
        }
		$this->display();
	}

}
